class ChangeCommentType < ActiveRecord::Migration
  def self.up
    ActiveRecord::Base.transaction do
      Comment.find(:all).each do |comment|
        discussion = Discussion.find_by_id(comment.commentable_id)
        article = Article.find_by_id(comment.commentable_id)

        if discussion
          comment.commentable_type = 'Discussion'
        end

        if article
          comment.commentable_type = 'Article'
        end

        comment.save!
      end
    end
  end

  def self.down
  end
end
